package zz.app.ustbgsmanager.adapters;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.ArrayList;

import zz.app.ustbgsmanager.R;
import zz.app.ustbgsmanager.beans.teachingassessment.CourseAssessment;

/**
 * Created by zz on 2018/6/11 21:12.
 */
public class TeachingAssessmentRecyclerViewAdapter extends RecyclerView.Adapter<TeachingAssessmentRecyclerViewAdapter.ViewHolder> {
    private static final String TAG = "TeachingAssessmentRecyc";
    private final Context context;

    public ArrayList<CourseAssessment> getData() {
        return data;
    }

    public void setData(ArrayList<CourseAssessment> data) {
        this.data = data;
        notifyDataSetChanged();
    }

    ArrayList<CourseAssessment> data;

    public TeachingAssessmentRecyclerViewAdapter(Context context) {
        this.context=context;
        data=new ArrayList<>();
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(context).inflate(R.layout.layout_teachingassessment_adapter,parent,false);
        ViewHolder viewHolder=new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        CourseAssessment datum=data.get(position);
        String s=datum.getKcmc()+" ("+datum.getNumber()+")";
        holder.tvName.setText(s);
        holder.tvTerm.setText(datum.getPjxq());
        holder.tvTeacher.setText(datum.getJsxm());

    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        public TextView tvName;
        public TextView tvTerm;
        public TextView tvTeacher;
        public ViewHolder(View itemView) {
            super(itemView);
            tvName=itemView.findViewById(R.id.tvName);
            tvTerm=itemView.findViewById(R.id.tvTerm);
            tvTeacher=itemView.findViewById(R.id.tvTeacher);
        }
    }
}
